<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>显示公告</title>
    <script src="js/sockjs.js"></script>
    <script src="js/stomp.js"></script>
    <script src="js/jquery-3.2.1.js"></script>
</head>
<body>
<p id="showNotice"></p>

<script type="text/javascript">

    $(document).ready(function () {

        var socket = new SockJS('/api-messages');

        stompClient = Stomp.over(socket);

        stompClient.connect({},function (frame) {
            console.log('开始进行连接Connected: ' + frame);
            stompClient.subscribe('/user/kong/tasks', function (message) {

                $('#showNotice').html(message.body);
            },function (errr) {
                $('#showNotice').html(errr);

            });

        });

    });


</script>
</body>
</html>